package hotel.menu.untils;

import hotel.menu.domain.Food;
import hotel.menu.domain.School;
import java.lang.reflect.Type;
import java.util.LinkedList;
import java.util.List;

import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;

public class GosnUtil {

	public static Gson gson = new Gson();
	/*
	 * public static final Type listType = new TypeToken<Card>() { }.getType();
	 */
	public static final Type musicListType = new TypeToken<LinkedList<School>>() {
	}.getType();
	public static final Type foodType = new TypeToken<LinkedList<Food>>() {
	}.getType();

	public static LinkedList<School> getObjectList(String jsonStr) {
		LinkedList<School> list = null;
		try {
			list = gson.fromJson(jsonStr, musicListType);
		} catch (Exception e) {
			e.printStackTrace();
		}
		return list;
	}
	
	public static List<Food> getFoodList(String jsonStr) {
		List<Food> list = null;
		try {
			list = gson.fromJson(jsonStr, foodType);
		} catch (Exception e) {
			e.printStackTrace();
		}
		return list;
	}


}
